export default {
    getDate(data,type) {
            let myDate;

            if (data instanceof Date){
                myDate = data;
            } else if (typeof(data) == 'number') {
                myDate = new Date(data);
            } else {
                return data;
            }

            let Y = myDate.getFullYear(),
                M = myDate.getMonth() + 1,
                D = myDate.getDate(),
                H = myDate.getHours(),
                Min = myDate.getMinutes(),
                S = myDate.getSeconds();

            if (M < 10) {
                M = '0' + M;
            }
            if (D < 10) {
                D = '0' + D;
            }
            if (H < 10) {
                H = '0' + H;
            }
            if (Min < 10) {
                Min = '0' + Min;
            }
            if (S < 10) {
                S = '0' + S;
            }

            if(type == 'date'){
                return Y + '-' + M + '-' + D ;
            }else if(type == 'time'){
                return Y + '-' + M + '-' + D +' '+ H + ':' +Min + ':' + S;
            }
        }
}
